

document.write("canal".lastIndexOf("a"));
document.write("<br>")
document.write("canal".lastIndexOf("a",0)); //lastIndexOf是从最后开始向前检索，所以fromIndex为0的话 返回-1
document.write("<br>")

var str = "How can mirrors be real if our eyes aren't real";
var str1="Three men, six options, don't choose.";

String.prototype.toJadenCase = function () {
  //...
  var reg=/[a-z]+[\-\']?[a-z]*/ig;
  var result= this.replace(reg,function(word){
    return word.replace(word.charAt(0),word.charAt(0).toUpperCase());
  });


  return result;
};

var arr=[1, 4, 9, 16, 25, 36];
function isSquareNum(arr){
  if(arr==null||arr==undefined||arr.length==0){
    return undefined;
  }

  //result长度与arr长度一样
  var result=[];
  for(index in arr){
    if(arr[index]===0||arr[index]===1){
      result[index]=true;
    }else{
      for(var i=1;i<arr[index];i++){
        var divResult=arr[index]/i;
        if(divResult===i){
          result[index]=true;
          break;
        }
      }
      if(result[index]==undefined){
        result[index]=false;
      }
    }
  }
//判断结果集合中是否有false
  for(value of result){
    if(value===false){
      return false
    }
  }
  return true;
}

function isSquareNum2(arr){
  return (arr.length)? arr.every(squareNum):undefined;
}

function squareNum(num){
   return Math.sqrt(num)%1==0;
}
console.log(isSquareNum2(arr));

// function toJadenCase(str){
//   var reg=/\b\w+\b/g;
//   return str.replace(reg,function(word){
//     return word.replace(word.charAt(0),word.charAt(0).toUpperCase());
//   });
// }


document.write(str.toJadenCase());
document.write('<br>');
document.write('<br>');
// document.write(str1.toJadenCase());
// document.write(toJadenCase(str));
